package com.sxit.myproscenium.system.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.sxit.myproscenium.common.response.R;
import com.sxit.myproscenium.system.entity.Notice;
import com.sxit.myproscenium.system.service.INoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 通知公告表 前端控制器
 *
 * @author wcn
 * @since 2022-04-14
 */
@RestController
@RequestMapping("/system/notice")
public class NoticeController {

  @Autowired private INoticeService noticeService;

  @GetMapping("/getAllNotice")
  public R getAllNotice() {

    QueryWrapper<Notice> noticeQueryWrapper = new QueryWrapper<>();
    noticeQueryWrapper.eq("status", 0);
    List<Notice> list = noticeService.list(noticeQueryWrapper);
    return R.ok().put("data", list);
  }

  @GetMapping("/getIndexNotice")
  public R getIndexNotice() {

    QueryWrapper<Notice> noticeQueryWrapper = new QueryWrapper<>();
    noticeQueryWrapper.eq("status", 0).eq("notice_title", "首页公告-可修改-不可删除");
    Notice one = noticeService.getOne(noticeQueryWrapper);
    return R.ok().put("data", one);
  }
}
